package com.kongxr.opengltest.shape;

import java.nio.ByteBuffer;
import java.nio.ByteOrder;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;

public class Square {

    static final int COORDS_PER_VERTEX = 3;
    static short[] draw_list_order = {1,2,3,0,1,3};
    static float[] coordinates = {
            0.5f, 0.6f, 0.0f,
            -0.5f, 0.6f, 0.0f,
            -0.5f, -0.6f, 0.0f,
            0.5f, -0.3f, 0.0f
    };
    public Square() {
        ByteBuffer byteBuffer = ByteBuffer.allocateDirect(coordinates.length * 4);
        byteBuffer.order(ByteOrder.nativeOrder());
        FloatBuffer vertexBuffer = byteBuffer.asFloatBuffer();
        vertexBuffer.put(coordinates);
        vertexBuffer.position(0);

        ByteBuffer byteBuffer1 = ByteBuffer.allocateDirect(coordinates.length * 2);
        byteBuffer1.order(ByteOrder.nativeOrder());
        ShortBuffer drawListBuffer = byteBuffer1.asShortBuffer();
        drawListBuffer.put(draw_list_order);
        drawListBuffer.position(0);

    }
}
